home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-05-07 | 2.8 KB | 61 lines | [TEXT/McSk] |
- ( Apple Events for Pocket Forth 0.6 and HyperCard 2.1 )
- forget task decimal 0 28 +md !
-
- 2variable DOSC.DATA 4 allot ( aedesc holder )
-
- : AEDisposeDesc ( r: room d.addr -- error )
- ( move.w #$0204,d0 _Pack8 ) ,$ 303C ,$ 0204 ,$ A816 ; macro
-
- : -DESC ( -- ) ( dispose of the descriptor )
- 0 >r dosc.data a>r ( push room and descriptor )
- AEDisposeDesc r> drop ; ( recklessly drop error )
-
- ( This word is installed into the idle handler by the apple event.)
- : DOSCIDLE ( -- ) ( interpret text whose handle is at above var. )
- [ ' null literal ] 20 +md ! ( reset idle routine to null )
-
- ( movea.l dd+4[bp],a0 ) ,$ 206B [ dosc.data 4 + , ] ( handle )
- ( _GetHandleSize ) ,$ A025 ( bytes to move in d0 )
- ( movea.l [a0],a0 ) ,$ 2050 ( source address in a0 )
- ( movea.l is,a1 ) ,$ 224C ( destination [is=a4] in a1 )
- ( _BlockMove ) ,$ A02E ( move data to input stream )
- -desc ( dispose of the descriptor )
- 13 tib 79 + c! ( follow input stream with a cr [ascii=13] )
- interpret [ ( jump to interpreter; see below )
-
- ( Follow a call to interpret with [ instead of ; since it will)
- ( never return. The interpreter will fix up the return stack )
- ( the text is interpreted. Until then, it's not a problem. )
-
- : AEGetParamDesc ( r: room d.evt d.key d.type d.addr -- error )
- ( move.w #$0812,d0 _Pack8 ) ,$ 303C ,$ 0812 ,$ A816 ; macro
-
- : ?DESC ( d.key d.type -- 8.AEDesc 1 or 0 ) ( get AEDesc handle )
- 0 >r ( room for error )
- 202 +md 2@ 2>r ( the AppleEvent )
- 2swap 2>r 2>r ( keyword and type )
- here a>r ( recieving address )
- AEGetParamDesc
- r> 0= IF ( if there is no error )
- here 4 + 2@ here 2@ -1 ( get data & leave true )
- ELSE 0 THEN ; ( or else leave false )
-
- ( The apple event handler for the 'dosc' or "do script" event from)
- ( HyperCard 2.1. Use "send [text] to program "Pocket Forth". )
- ,s dosc ,s misc ae: ( mon )
- ,s ---- ,s TEXT ?desc IF ( if there is no error )
- dosc.data 2! dosc.data 4 + 2! ( store handle to the data )
- [ ' doscIdle literal ] 20 +md ! ( set idle routine to above)
- THEN
- ;ae
-
- -1 28 +md ! ( restore echo )
- page beep beep beep
- ( Press any key to install a 'Do Script' Apple Event into )
- ( this copy of Pocket Forth. Do this ONLY if this is a )
- ( COPY of Pocket Forth. If you need to bail out and make )
- ( a copy, close this window, or choose Quit from the menu.)
- key drop
- : task ; ( protect this from "forget task" )
- save bye ( Re-open me! )
-